package com.example.marketapp.dao;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.marketapp.*;
import com.example.marketapp.model.Cliente;

public class ClienteAdapter extends BaseAdapter {
	private Context context;
	private List<Cliente> cliente;
	private int layout;

	public ClienteAdapter(Context context, int layout, List<Cliente> cliente) {
		this.context = context;
		this.cliente = cliente;
		this.layout = layout;
	}

	public int getCount() {
		return cliente.size();
	}

	public long getItemId(int posicao) {
		return cliente.get(posicao).getId();
	}

	public Object getItem(int posicao) {
		return cliente.get(posicao);
	}

	public View getView(int posicao, View convertView, ViewGroup parent) {

		cliente.get(posicao);

		LayoutInflater layoutInflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View view = layoutInflater.inflate(this.layout, null);

		TextView nome = (TextView) view.findViewById(R.id.nome);
		nome.setText(cliente.toString());

		return view;

	}

}
